﻿@inherits GroupsBase

<EditPage @ref="EditPage" Id="group" FixedHeader="@FixedHeader" TItem="Bootstrap.DataAccess.Group" SubmitModalTitle="部门编辑窗口" QueryModel="QueryModel" OnQuery="Query" OnAdd="Add" OnDelete="Delete" OnSave="Save" OnResetSearch="ResetSearch">
    <QueryBody>
        <LgbInputText ColumnClass="col-sm-auto" @bind-Value="@context.GroupName" maxlength="50" />
        <LgbInputText ColumnClass="col-sm-auto" @bind-Value="@context.Description" maxlength="50" />
    </QueryBody>
    <TableToolbarTemplate>
        <TableToolbarButton class="btn btn-info" Icon="fa fa-user" Title="分配用户" OnClick="AssignUsers" />
        <TableToolbarButton class="btn btn-warning" Icon="fa fa-sitemap" Title="分配角色" OnClick="AssignRoles" />
    </TableToolbarTemplate>
    <TableHeader>
        <LgbTableHeader TItem="string" @bind-Value="@context.GroupCode" Sort="true"></LgbTableHeader>
        <LgbTableHeader TItem="string" @bind-Value="@context.GroupName" Sort="true"></LgbTableHeader>
        <LgbTableHeader TItem="string" @bind-Value="@context.Description" Sort="true"></LgbTableHeader>
    </TableHeader>
    <RowTemplate>
        <td>@context.GroupCode</td>
        <td>@context.GroupName</td>
        <td>@context.Description</td>
    </RowTemplate>
    <EditTemplate>
        <div class="row">
            <LgbInputText @bind-Value="@context.GroupName" placeholder="不可为空，50字以内" maxlength="50">
                <RequiredValidator />
                <StringLengthValidator Length="50" />
            </LgbInputText>
            <LgbInputText @bind-Value="@context.GroupCode" placeholder="不可为空，50字以内" maxlength="50">
                <RequiredValidator />
                <StringLengthValidator Length="50" />
            </LgbInputText>
            <LgbInputText @bind-Value="@context.Description" placeholder="不可为空，500字以内" maxlength="500">
                <RequiredValidator />
                <StringLengthValidator Length="500" />
            </LgbInputText>
        </div>
    </EditTemplate>
</EditPage>

<AssignModal @ref="AssignUserModal" TItem="Bootstrap.DataAccess.User" Id="group-user" Title="用户授权窗口" OnSave="SaveUsers">
    <ItemTemplate>
        <Checkbox TItem="Bootstrap.DataAccess.User" Item="@context" Text="@context.FormatDisplayName()" SetCheckCallback="SetUserCheck" OnClick="OnUserClick" />
    </ItemTemplate>
</AssignModal>

<AssignModal @ref="AssignRoleModal" TItem="Bootstrap.DataAccess.Role" Id="group-role" Title="角色授权窗口" OnSave="SaveRoles">
    <ItemTemplate>
        <Checkbox TItem="Bootstrap.DataAccess.Role" Item="@context" Text="@context.RoleName" SetCheckCallback="SetCheck" OnClick="OnClick" />
    </ItemTemplate>
</AssignModal>
